package com.xiyu.service.repository.customer.contact;

import com.xiyu.service.model.customer.contact.CustomerContactSocialMedia;
import com.xiyu.service.model.customer.contact.CustomerContactSocialMediaTable;
import org.babyfish.jimmer.spring.repository.JRepository;

import java.util.List;

public interface CustomerContactSocialMediaRepository extends JRepository<CustomerContactSocialMedia, Long> {
    CustomerContactSocialMediaTable customerContactSocialMediaTable = CustomerContactSocialMediaTable.$;

    default void deleteByCustomerIds(List<Long> customerIds){
        sql().createDelete(customerContactSocialMediaTable)
                .where(customerContactSocialMediaTable.contact().customerId().in(customerIds))
                .execute();
    }

    default void deleteByExcludeId(Long contactId, List<Long> ids){
        sql().createDelete(customerContactSocialMediaTable)
                .where(customerContactSocialMediaTable.contactId().eq(contactId))
                .where(customerContactSocialMediaTable.id().notIn(ids))
                .execute();
    }

    List<CustomerContactSocialMedia> findByContactId(Long contactId);

}